package com.laikan.reader.core.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import com.laikan.reader.core.LaikanBaseAdapter;
import com.laikan.reader.R;
import com.laikan.reader.core.bean.Consume;

import java.util.ArrayList;

/**
 * @author wx 消费记录listview的适配器
 */
public class Personal_Consume_Adapter extends LaikanBaseAdapter<Consume> {

    public Personal_Consume_Adapter(Context context, ArrayList<Consume> moreList) {
        super(context, moreList);
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {

        if (convertView == null) {
            convertView = View.inflate(mContext, R.layout.personal_consume_item, null);

        }
        TextView content1 = (TextView)convertView.findViewById(R.id.text1);
        TextView content2 = (TextView)convertView.findViewById(R.id.text2);
        TextView time = (TextView)convertView.findViewById(R.id.text3);
        TextView money = (TextView)convertView.findViewById(R.id.text4);
        TextView type = (TextView)convertView.findViewById(R.id.text5);
        String[] str = datas.get(position).getContent().split("》");

        try {
            content1.setText(str[0] + "》");
            content2.setText(str[1]);
        }catch (Exception e) {
            content2.setText("");
        }

        time.setText(datas.get(position).getDate());
        float moneyMath = Float.parseFloat(datas.get(position).getMoney()) / 100;
        money.setText("-" + datas.get(position).getMoney());
        if (datas.get(position).getType().equals("65") || datas.get(position).getType().equals("68")) {
            type.setText("阅读券");
        }else {
            type.setText("K币");
        }
        return convertView;
    }

}
